# Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@rules_cc//cc:defs.bzl", "cc_test")
load("//bazel:configure_file.bzl", "configure_file")

configure_file(
    name = "test_input_path_hpp",
    src = "moduletests/test_input_path.hpp.in",
    out = "iceoryx/tests/posh/moduletests/test_input_path.hpp",
    config = {
        "POSH_TEST_INPUT_FILES_PATH": "iceoryx_posh/test/input/",
    },
)

cc_test(
    name = "posh_moduletests",
    srcs = glob([
        "moduletests/*.cpp",
        "moduletests/*.hpp",
        "mocks/*.hpp",
        "stubs/*.hpp",
        "*.hpp",
    ]) + [":test_input_path_hpp"],
    data = glob(["input/**"]),
    includes = [
        ".",
        "mocks",
        "moduletests",
        "stubs",
    ],
    linkopts = select({
        "//iceoryx_platform:linux": ["-ldl"],
        "//iceoryx_platform:mac": [],
        "//iceoryx_platform:qnx": [],
        "//iceoryx_platform:unix": [],
        "//iceoryx_platform:win": [],
        "//conditions:default": ["-ldl"],
    }),
    tags = ["exclusive"],
    visibility = ["//visibility:private"],
    deps = [
        "//iceoryx_hoofs:iceoryx_hoofs_testing",
        "//iceoryx_posh",
        "//iceoryx_posh:iceoryx_posh_config",
        "//iceoryx_posh:iceoryx_posh_testing",
        "@cpptoml",
    ],
)

cc_test(
    name = "posh_integrationtests",
    srcs = glob([
        "integrationtests/*.cpp",
        "integrationtests/*.hpp",
        "*.hpp",
    ]),
    includes = [
        ".",
        "integrationtests",
    ],
    linkopts = select({
        "//iceoryx_platform:linux": ["-ldl"],
        "//iceoryx_platform:mac": [],
        "//iceoryx_platform:qnx": [],
        "//iceoryx_platform:unix": [],
        "//iceoryx_platform:win": [],
        "//conditions:default": ["-ldl"],
    }),
    tags = ["exclusive"],
    visibility = ["//visibility:private"],
    deps = [
        "//iceoryx_hoofs:iceoryx_hoofs_testing",
        "//iceoryx_posh",
        "//iceoryx_posh:iceoryx_posh_gateway",
        "//iceoryx_posh:iceoryx_posh_testing",
    ],
)
